package handler

import (
	"github.com/gin-gonic/gin"
	"post-hub/internal/dto"
	"post-hub/internal/model"
	"post-hub/pkg"
	"post-hub/response"
)

func CreatePost(c *gin.Context) {

	var post model.Post
	err := c.ShouldBind(&post)
	if err != nil {
		response.Error(c, "解析失败")
		return
	}
	post = model.Post{
		Title:   post.Title,
		Image:   post.Image,
		Content: post.Content,
		Qx:      post.Qx,
		Status:  "审核中",
	}
	pkg.Text()
	err = dto.CreatePost(&post)
	if err != nil {
		response.Error(c, "发布失败")
		return
	}
	response.Success(c, "发布成功", post.Status)

}
